<!--
 * @Author: daidai
 * @Date: 2022-03-01 09:43:37
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-09-09 11:40:22
 * @FilePath: \web-pc\src\pages\big-screen\view\indexs\left-bottom.vue
-->
<template>
  <!-- <div
    v-if="pageflag"
    class="left_boottom_wrap beautify-scroll-def"
    :class="{ 'overflow-y-auto': !sbtxSwiperFlag }"
  >
    <component :is="components" :data="list" :class-option="defaultOption">
      <ul class="left_boottom">
        <li class="left_boottom_item" v-for="(item, i) in list" :key="i">
          <span class="orderNum doudong">{{ i + 1 }}</span>
          <div class="inner_right">
            <div class="dibu"></div>
            <div class="flex">
              <div class="info">
                <span class="labels">设备ID：</span>
                <span class="contents zhuyao doudong wangguan">
                  {{ item.gatewayno }}</span
                >
              </div>
              <div class="info">
                <span class="labels">时间：</span>
                <span class="contents " style="font-size: 12px">
                  {{ item.createTime }}</span
                >
              </div>
            </div>

              <span
                class="types doudong"
                :class="{
                  typeRed: item.onlineState == 0,
                  typeGreen: item.onlineState == 1,
                }"
                >{{ item.onlineState == 1 ? "上线" : "下线" }}</span
              >

            <div class="info addresswrap">
              <span class="labels">地址：</span>
              <span class="contents ciyao" style="font-size: 12px">
                {{ addressHandle(item) }}</span
              >
            </div>
          </div>
        </li>
      </ul>
    </component>
  </div>

  <Reacquire v-else @onclick="getData" style="line-height: 200px" /> -->
  <div class="container">
    <div class="icon-list">
      <div class="item">
        <img src="../../assets/img/custom/总数@2x.png" alt="" class="bg" />
        <div class="info">
          <div class="info-num">15</div>
          <div class="info-title">总数</div>
        </div>
      </div>

      <div class="item">
        <img src="../../assets/img/custom/总数@2x.png" alt="" class="bg" />
        <div class="info">
          <div class="info-num">5</div>
          <div class="info-title">预约数</div>
        </div>
      </div>

      <div class="item">
        <img src="../../assets/img/custom/总数@2x.png" alt="" class="bg" />
        <div class="info">
          <div class="info-num">33%</div>
          <div class="info-title">预约比率</div>
        </div>
      </div>
    </div>
    <div class="chat">
      <Echart
        id="rightTop"
        :options="option"
        class="right_top_inner"
        v-if="pageflag"
        ref="charts"
      />
    </div>
  </div>
</template>

<script>
import { currentGET } from "api/modules"
import { graphic } from "echarts"
export default {
  data() {
    return {
      option: {},
      pageflag: false,
      timer: null,
    }
  },
  created() {},

  mounted() {
    this.getData()
  },
  beforeDestroy() {
    this.clearData()
  },
  methods: {
    clearData() {
      if (this.timer) {
        clearInterval(this.timer)
        this.timer = null
      }
    },
    getData() {
      this.pageflag = true
      // this.pageflag =false
      currentGET("big4").then(res => {
        if (!this.timer) {
          console.log("报警次数", res)
        }
        if (res.success) {
          this.countUserNumData = res.data
          this.$nextTick(() => {
            this.init(res.data.dateList, res.data.numList, res.data.numList2), this.switper()
          })
        } else {
          this.pageflag = false
          this.$Message({
            text: res.msg,
            type: "warning",
          })
        }
      })
    },
    //轮询
    switper() {
      if (this.timer) {
        return
      }
      let looper = a => {
        this.getData()
      }
      this.timer = setInterval(looper, this.$store.state.setting.echartsAutoTime)
      let myChart = this.$refs.charts.chart
      myChart.on("mouseover", params => {
        this.clearData()
      })
      myChart.on("mouseout", params => {
        this.timer = setInterval(looper, this.$store.state.setting.echartsAutoTime)
      })
    },
    init(xData, yData, yData2) {
      console.log({
        xData,
        yData,
      })
      this.option = {
        xAxis: {
          type: "category",
          data: xData,
          boundaryGap: false, // 不留白，从原点开始
          splitLine: {
            show: true,
            lineStyle: {
              color: "rgba(31,99,163,.2)",
            },
          },
          axisLine: {
            // show:false,
            lineStyle: {
              color: "rgba(31,99,163,.1)",
            },
          },
          axisLabel: {
            color: "rgba(255, 255, 255, 0.65)",
            fontSize: "13",
          },
        },
        yAxis: {
          type: "value",
          splitLine: {
            show: true,
            lineStyle: {
              color: "rgba(31,99,163,.2)",
            },
          },
          axisLine: {
            lineStyle: {
              color: "rgba(31,99,163,.1)",
            },
          },
          axisLabel: {
            color: "rgba(255, 255, 255, 0.65)",
            fontSize: "13",
          },
        },
        tooltip: {
          trigger: "axis",
          backgroundColor: "rgba(0,0,0,.6)",
          borderColor: "rgba(147, 235, 248, .8)",
          textStyle: {
            color: "#FFF",
          },
        },
        grid: {
          //布局
          show: true,
          left: "10px",
          right: "30px",
          bottom: "10px",
          top: "28px",
          containLabel: true,
          borderColor: "#1F63A3",
        },
        series: [
          {
            data: yData,
            type: "line",
            smooth: true,
            symbol: "none", //去除点
            name: "报警1次数",
            color: "rgba(255,34,104,.7)",
            areaStyle: {
              //右，下，左，上
              color: new graphic.LinearGradient(
                0,
                0,
                0,
                1,
                [
                  {
                    offset: 0,
                    color: "rgba(255,34,104,.7)",
                  },
                  {
                    offset: 1,
                    color: "rgba(252,144,16,.0)",
                  },
                ],
                false
              ),
            },
            markPoint: {
              data: [
                {
                  name: "最大值",
                  type: "max",
                  valueDim: "y",
                  symbol: "rect",
                  symbolSize: [60, 26],
                  symbolOffset: [0, -20],
                  itemStyle: {
                    color: "rgba(0,0,0,0)",
                  },
                  label: {
                    color: "#FC6F9A ",
                    backgroundColor: "rgba(252,144,16,0.1)",
                    borderRadius: 6,
                    padding: [7, 14],
                    borderWidth: 0.5,
                    borderColor: "rgba(252,111,154,.9)",
                    formatter: "报警：{c}",
                  },
                },
                {
                  name: "最大值",
                  type: "max",
                  valueDim: "y",
                  symbol: "circle",
                  symbolSize: 6,
                  itemStyle: {
                    color: "##FF2268",
                    shadowColor: "##FF2268",
                    shadowBlur: 8,
                  },
                  label: {
                    formatter: "",
                  },
                },
              ],
            },
          },
          // {
          //   data: yData2,
          //   type: "line",
          //   smooth: true,
          //   symbol: "none", //去除点
          //   name: "报警2次数",
          //   color: "rgba(9,202,243,.7)",
          //   areaStyle: {
          //     //右，下，左，上
          //     color: new graphic.LinearGradient(
          //       0,
          //       0,
          //       0,
          //       1,
          //       [
          //         {
          //           offset: 0,
          //           color: "rgba(9,202,243,.7)",
          //         },
          //         {
          //           offset: 1,
          //           color: "rgba(9,202,243,.0)",
          //         },
          //       ],
          //       false
          //     ),
          //   },
          //   markPoint: {
          //     data: [
          //       {
          //         name: "最大值",
          //         type: "max",
          //         valueDim: "y",
          //         symbol: "rect",
          //         symbolSize: [60, 26],
          //         symbolOffset: [0, -20],
          //         itemStyle: {
          //           color: "rgba(0,0,0,0)",
          //         },
          //         label: {
          //           color: "#09CAF3",
          //           backgroundColor: "rgba(9,202,243,0.1)",

          //           borderRadius: 6,
          //           borderColor: "rgba(9,202,243,.5)",
          //           padding: [7, 14],
          //           formatter: "报警2：{c}",
          //           borderWidth: 0.5,
          //         },
          //       },
          //       {
          //         name: "最大值",
          //         type: "max",
          //         valueDim: "y",
          //         symbol: "circle",
          //         symbolSize: 6,
          //         itemStyle: {
          //           color: "#09CAF3",
          //           shadowColor: "#09CAF3",
          //           shadowBlur: 8,
          //         },
          //         label: {
          //           formatter: "",
          //         },
          //       },
          //     ],
          //   },
          // },
        ],
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.container {
  .chat {
    position: relative;
    z-index: 9;
    transform: translateY(-30px);
    ::v-deep canvas {
      width: 100% !important;
      height: 130px !important;
    }
  }
  .icon-list {
    display: flex;
    align-items: center;
    justify-content: space-around;
    gap: 50px;
    transform: translateY(-10px);
    .item {
      flex: 1;
      height: 160px;
      gap: 20px;
      position: relative;
      box-sizing: border-box;
      padding: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      .bg {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 1;
      }
      .info {
        position: relative;
        z-index: 2;
        text-align: center;
        .info-num {
          color: #23d1ff;
          font-size: 24px;
        }
        .info-title {
          color: #ceecff;
          font-size: 16px;
          margin-top: 10px;
        }
      }
    }
  }
}
.left_boottom_wrap {
  overflow: hidden;
  width: 100%;
  height: 100%;
}

.doudong {
  //  vertical-align:middle;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  -moz-backface-visibility: hidden;
  -ms-backface-visibility: hidden;
  backface-visibility: hidden;
}

.overflow-y-auto {
  overflow-y: auto;
}

.left_boottom {
  width: 100%;
  height: 100%;

  .left_boottom_item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    font-size: 14px;
    margin: 10px 0;
    .orderNum {
      margin: 0 16px 0 -20px;
    }

    .info {
      margin-right: 10px;
      display: flex;
      align-items: center;
      color: #fff;

      .labels {
        flex-shrink: 0;
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
      }

      .zhuyao {
        color: $primary-color;
        font-size: 15px;
      }

      .ciyao {
        color: rgba(255, 255, 255, 0.8);
      }

      .warning {
        color: #e6a23c;
        font-size: 15px;
      }
    }

    .inner_right {
      position: relative;
      height: 100%;
      width: 380px;
      flex-shrink: 0;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: space-between;
      flex-wrap: wrap;
      .dibu {
        position: absolute;
        height: 2px;
        width: 104%;
        background-image: url("../../assets/img/zuo_xuxian.png");
        bottom: -10px;
        left: -2%;
        background-size: cover;
      }
      .addresswrap {
        width: 100%;
        display: flex;
        margin-top: 8px;
      }
    }

    .wangguan {
      color: #1890ff;
      font-weight: 900;
      font-size: 15px;
      width: 80px;
      flex-shrink: 0;
    }

    .time {
      font-size: 12px;
      // color: rgba(211, 210, 210,.8);
      color: #fff;
    }

    .address {
      font-size: 12px;
      cursor: pointer;
      // @include text-overflow(1);
    }

    .types {
      width: 30px;
      flex-shrink: 0;
    }

    .typeRed {
      color: #fc1a1a;
    }

    .typeGreen {
      color: #29fc29;
    }
  }
}
</style>
